<?php
session_start();
require_once( 'employee_db.php' );
 
$m_emp = new M_Employee();
$user_id = $_SESSION['userid'];

if (isset($_POST['m'])  &&  $_POST['m']!=""){

    if ($_POST['m']== 'load'){
		$_df = $_POST['date_from'];
		$_dt = $_POST['date_to'];
		$_name = $_POST['name'];
		$result=$m_emp->loadNotice($_name, $_df, $_dt);
		if ($m_emp->getRowCount()>0){
			$data = array();
			while($row=$result->FetchRow()){
				  $data[] =array(0,$row['id'],$row['noticedate'], $row['title']
					, $row['titled'].' ' .$row['nameed']
					, $row['title_by'].' ' .$row['name']);
			}
		}else{
			$data = array();
		}
		
        $arr = array('aaData'=>$data);
        
        echo json_encode($arr);
      
    }else if ($_POST['m']=='add'){
        $ar = array();
 
		$ar['detail']=  $_POST['detail'];
		$ar['noticed']=  $_POST['noticed'];
		$ar['title']= $_POST['title'];
		$ar['notice_date'] =date( "Y/m/d H:i:s" );
		$ar['notice_by'] = $user_id ;
		 
		$m_emp->addNotice($ar);
		
    }else if ($_POST['m']=='del'){
         $id=$_POST['id'];
		 $m_emp->deleNotice($id);
		 
    }/// Age Criteria
	    
}else{
	if (isset($_GET['m']) && $_GET['m'] !="" ){
		if($_GET['m']=='emp')
			echo json_encode( $m_emp->getEmployee());
		else if($_GET['m']=='l')
			echo json_encode( $type->getLeave('Y'));
		 
	}
}
 
?>